package com.ruoyi.project.system.controller;

import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.PatientList;
import com.ruoyi.project.system.service.IPatientListService;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/patients")
public class PatientListController {

    @Autowired
    private IPatientListService patientListService;

    /**
     * 获取当前医生当前时段的患者列表
     * 接口地址: GET /patients/current-slot
     */
    @GetMapping("/current-slot")
    public AjaxResult getCurrentSlotPatients() {
        // 1. 从 Token 中获取当前登录医生的 ID
        Long doctorId = SecurityUtils.getUserId();

        // 2. 调用 Service 层方法查询数据
        List<PatientList> patientList = patientListService.getCurrentDayPatients(doctorId);

        // 3. 返回结果
        return AjaxResult.success(patientList);
    }
}